package fi.helsinki.cs.ohtu10k.schedule;

import org.joda.time.DateTime;
import org.joda.time.Duration;

/**
 * Interface for Manager class for Calendar events and courses.
 * @author Thomas Nyman
 * @author Jani Rönkä
 *
 */
public interface ScheduleManager {
	
	/**
	 * Returns <code>true</code> if no courses of events are associated with the manager.
	 * @return <code>true</code> if no courses of events are associated with the manager.
	 */
	public boolean isEmpty();
	
	/**
	 * Returns array of events with start date between specified start date and end date.
	 * @param startDate Starting bound of search.
	 * @param endDate 	End bound of search.
	 * @return Array of events with start date between startDare and endDate.
	 */
	public ScheduleEvent[] getEvents(DateTime startDate, DateTime endDate);
	
	/**
	 * Returns array of courses associated with the manager.
	 * @return Array of courses associated with the manager.
	 */
	public ScheduleCourse[] getCourses();
	
	/**
	 * Adds new course to manager with specified attributes.
	 * @param startDate Start Date of course.
	 * @param endDate	End date of course.
	 * @param name		Name of course 
	 * @param abbr		Abbreviation of course.
	 * @throws IllegalArgumentException
	 */
	public void addCourse(DateTime startDate, DateTime endDate, String name, String abbr) 
		throws IllegalArgumentException;
	
	/**
	 * Removes specified course from manager if present.
	 * Removal of course should lead to removal of all events associated with course.
	 * @param course Course to remove.
	 * @throws IllegalArgumentException If course <code>null</code> or not found. 
	 */
	public void delCourse(ScheduleCourse course) throws IllegalArgumentException;
	
	/**
	 * Returns <code>true</code> if manager contains specified course, else <code>false</code>. 
	 * @param course Course to search for.
	 * @return <code>true</code> if manager contains specified course, else <code>false</code>.
	 * @throws IllegalArgumentException If specified course is <code>null</code>.
	 */
	public boolean containsCourse(ScheduleCourse course) throws IllegalArgumentException;
	
	/**
	 * Adds new event to manager with specified attributes. 
	 * @param startDate		Start date of event.
	 * @param duration		Duration of event.
	 * @param name			Name of event.
	 * @param course		Course event belongs to, null if none
	 * @param isNotifiable	<code>true</code>  if user should be notified of this event, otherwise <code>false</code>.
	 * @throws IllegalArgumentException
	 * @throws TimeSlotTakenException	If time slot is already in use.
	 */
	public void addEvent(DateTime startDate, Duration duration, 
						 String name, ScheduleCourse course, 
						 boolean isNotifiable) throws IllegalArgumentException, 
						 TimeSlotTakenException;
	
	/**
	 * Adds new event to manager with specified attributes. 
	 * @param startDate		Start date of event.
	 * @param duration		Duration of event.
	 * @param name			Name of event.
	 * @param isNotifiable	<code>true</code> if user should be notified of this event, otherwise <code>false</code>.
	 * @throws IllegalArgumentException
	 * @throws TimeSlotTakenException	If time slot is already in use.
	 */
	public void addEvent(DateTime startDate, Duration duration, 
						 String name, boolean isNotifiable) throws IllegalArgumentException, 
						 TimeSlotTakenException;
	
	/**
	 * Removes specified event from manager if present.
	 * @param event		Event to be removed.
	 * @throws IllegalArgumentException If event <code>null</code> or not found.
	 */
	public void delEvent(ScheduleEvent event) throws IllegalArgumentException;
	
	/**
	 * Returns <code>true</code> if manager contains specified event, else <code>false</code>. 
	 * @param course Course to search for.
	 * @return <code>true</code> if manager contains specified event, else <code>false</code>.
	 * @throws IllegalArgumentException If specified event is <code>null</code>.
	 */
	public boolean containsEvent(ScheduleEvent event) throws IllegalArgumentException;

}
